import request from '@/config/axios'
import type { UserType } from './types'

interface RoleParams {
  roleName: string
}
export const loginApi = (params: UserType): Promise<IResponse<UserType>> => {
  return request.post({ url: '/api/login', params })
}
//查询用户信息
export const user = (str: string) => {
  return request.post({ url: '/api/getEnabled', params:{ str } })
}
//修改密码
export const uppassword = (id: string,newpwd : string): Promise<IResponse<UserType>> => {
  return request.post({ url: '/api/account/updUserPwd', params:{id,newpwd} })
}
export const loginOutApi = (): Promise<IResponse> => {
  return request.get({ url: '/user/loginOut' })
}

export const getUserListApi = ({ params }: AxiosConfig) => {
  return request.get<{
    total: number
    list: UserType[]
  }>({ url: '/user/list', params })
}

export const getAdminRoleApi = (
  params: RoleParams
): Promise<IResponse<AppCustomRouteRecordRaw[]>> => {
  return request.get({ url: '/role/list', params })
}

export const getTestRoleApi = (params: RoleParams): Promise<IResponse<string[]>> => {
  return request.get({ url: '/role/list', params })
}
